import os
import pickle

from src.common.cache import cacheFolder
from src.utils.debug_tools import print_debug

cachPath = cacheFolder


def cache_item(name, item):
    with open(os.path.join(cachPath, f"{name}.cache"), "wb") as f:
        pickle.dump(item, f)


def load_item(name):
    try:
        with open(os.path.join(cachPath, f"{name}.cache"), "rb") as f:
            return pickle.load(f)
    except Exception as e:
        return None
